<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>What If</title>
		<link href="CSS/style.css" rel="stylesheet" type="text/css" />
        <script language="javascript" type="text/javascript"> 
        	var stevecParametrov = 1;

        	function prenesiParametre(){
        		var par = document.getElementsByName("par");
            	var utez = document.getElementsByName("utez");
            	var alt1 = document.getElementById("alt1").innerHTML;
            	var alt2 = document.getElementById("alt2").innerHTML;
            	var link = "?alt1=" + alt1 + "&alt2=" + alt2 + "&stPar=" + par.length;
            	var i;
            	for (i=0; i < par.length; i++){
                	link += "&par" + i + "=" + par[i].value + "&utez" + i + "=" + utez[i].value;
            	}
            	window.location = "izracun.html" + link;
        	}
        	
			function alternative(alt1, alt2){
				document.getElementById("alt1").innerHTML = alt1;
				document.getElementById("alt2").innerHTML = alt2;
			}
		              		
			function vnesiAlternative(){
				sredina = document.documentElement.clientWidth
				okno = window.open("alternative.html","_blank","toolbar=no, location=no,, status=no, menubar=no, scrollbars=no, resizable=no, location=1, width=400, height=130");
				okno.moveTo(((sredina/2)-208),195);
			}
			
			function dodajParameter(tabela, vrsta){ 
		        var textbox = '<span class="sredina"><input type="text" name="par" id="par' + stevecParametrov + '" /></span>';
		        var dropDown = '<select name="utez"><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option><option>10</option></select>';
		        var remove = '<span class="sredina"><input type="button" name="odstrani' + stevecParametrov + '" value="Odstrani" onclick="odstraniVrsto(\'' + tabela + '\',\'' + stevecParametrov + '\')" /></span>';
		
	        	tabela = document.getElementById(tabela);
	            var novaVrstica = tabela.insertRow(stevecParametrov);
	            var novaCelica = novaVrstica.insertCell(0);
	            novaCelica.innerHTML = textbox;
	            novaCelica = novaVrstica.insertCell(1);
	            novaCelica.innerHTML = dropDown;
	            novaCelica = novaVrstica.insertCell(2);
	            novaCelica.innerHTML = remove;
	            stevecParametrov++; 
		    }
		
			function odstraniVrsto(tabela,vrsta){
			    tabela = document.getElementById(tabela);
			   
		    	stevecParametrov--;
		        tabela.deleteRow(vrsta);
			}
		</script>
	</head>
  
    <body onLoad="vnesiAlternative()">
    	<div class="main" align="center">
			<table width="400" border="0" align="center">
				<tr>
					<th><h1>What If</h1></th>
				</tr>
    		  	<tr>
					<td align="center">
                    	<br />
                  		<table width="80%" cellpadding="5" class="alternative" id="table1">
                            <tr>
                                <th width="50%">Prva alternativa:</th>
                                <td width="50%" id="alt1"></td>
                            </tr>
                            <tr>
                                <th width="50%">Druga alternativa:</th>
                                <td width="50%" id="alt2"></td>
                            </tr>
  		      			</table>
               			<br />
                  		<table class="parametri" id="parametri">
                    		<tr id="dodajNovo">
                      			<th width="160" align="center">Ime parametra</th>
                   			  	<th width="50" align="center">Uteži</th>
                      			<th width="80" align="center">briši</th>
                                <th width="50" align="center"></th>
                    		</tr>
                    		<tr ID="dodaj">
                      			<td colspan="2" align="center"><input type="submit" name="koncaj" value="Končaj" onClick="prenesiParametre()" /></td>
               			  	  	<td colspan="2" align="center"><input type="button" name="dodajParameter" value="Dodaj parameter" onClick="dodajParameter('parametri','dodajNovo')" /></td>
                    		</tr>
						</table>
                        <br />
                	</td>
				</tr>
			</table>
    	</div>
    </body>
</html>
